package com.itheima.dao;

import com.itheima.pojo.Contact;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @author MaQing
 * @create 2022-05-10 14:57
 */
public interface ContactMapper {
    @Insert("insert into contact values(null,#{name},#{sex},#{age},#{address},#{qq},#{email})")
    public int addContact(Contact contact);

    @Select("select * from contact where id = #{id}")
    Contact findContact(String id);

    @Update("update contact set name=#{name},sex=#{sex},age=#{age},address=#{address},qq=#{qq},email=#{email} where id=#{id}")
    int updateContact(Contact contact);

    @Delete("delete from contact where id = #{id}")
    int deleteContactById(String id);

    //用的xml
    List<Contact>findByCondition(Map<String, String> map);

    @Select("select * from contact limit #{startIndex},#{pageSize}")
    List<Contact> findByPage(@Param("startIndex") int startIndex, @Param("pageSize") int pageSize);
}
